import { _decorator, Component, ICollisionEvent, Node } from 'cc';
import { Barrier } from './Barrier';
import { Group } from './GameConstant';
import { GameManager } from './GameManager';
import { PoolManager } from '../AshFramework/Managers/PoolManager';
const { ccclass, property } = _decorator;

@ccclass('Handrail')
export class Handrail extends Barrier {

    protected onLoad(): void {
        super.onLoad();
        this.Collider.on(`onCollisionStay`, this.onCollisionStay, this);
    }

    onCollisionStay(event: ICollisionEvent) {
        if (event.otherCollider.getGroup() == Group.Weapon) {
            GameManager.Instance.repulsed();
        } else if (event.otherCollider.getGroup() == Group.Bullet) {
            PoolManager.PutNode(event.otherCollider.node);
        }
    }
}


